package IC.SymbolTable;

import IC.Types.*;
/**
 * This class represent the symbol object 
 */
public class Symbol {

	private String id;							//Symbol ID
	private Type type;							//Symbol Type
	private SymbolKind kind;					//Symbol Kind
	private final int appOrder;				    //Symbol appearance order
	private int scopeUniqueID;					//Symbol scope Unique ID
	private SymbolTable SymbolTableRef;			//Symbol Symbol table reference
		
	//C'tor
	public Symbol(String id, Type type, SymbolKind kind, int appOrder) {
		this.id = id;
		this.type = type;
		this.kind = kind;
		this.appOrder = appOrder;
	}
	
	//C'tor
	public Symbol(String id, Type type, SymbolKind kind) {
		this(id, type, kind, SymbolTable.NO_APPERANCE_ORDER);
	}

	public String getId() {
		return id;
	}

	public Type getType() {
		return type;
	}

	public SymbolKind getKind() {
		return kind;
	}
	
	public SymbolTable getSymbolTableRef() {
		return SymbolTableRef;
	}
	
	public int getAppOrder() {
		return appOrder;
	}
	
	protected void setScopeUniqueID(int scopeUniqueID) {
		this.scopeUniqueID = scopeUniqueID;
	}

	public int getScopeUniqueID() {
		return scopeUniqueID;
	}

	protected void setSymbolTableRef(SymbolTable St) {
		this.SymbolTableRef = St;
	}

	@Override
	public String toString() {
		switch (kind) 
		{
			case CLASS:
				return kind + ": " + type;	
			case STATIC_METHOD:
			case VIRTUAL_METHOD:
				return kind + ": " + id + " " + type;	
			default:
				return kind + ": " + type + " " + id;	
		}
	}
}

